package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.RoleDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.Role;
import com.itheima.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;


@Service(interfaceClass = RoleService.class)
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleDao roleDao ;

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        Integer currentPage = queryPageBean.getCurrentPage();
        Integer pageSize = queryPageBean.getPageSize();
        String queryString = queryPageBean.getQueryString();
        //使用分页助手插件实现分页查询
        PageHelper.startPage(currentPage,pageSize);
        Page<Role> page = roleDao.findByCondition(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }

    //添加基本信息,以及role和user表的关联信息
 //   public void add(Role role, Integer[] userIds, Integer[] permissionIds, Integer[] menuIds) {
      //  roleDao.add(role);
        /*Integer roleId = role.getId();//获得roleid
        //设置三个多对多关系.
        this.setRoleAndUser(roleId, userIds);
        this.setRoleAndPermission(roleId, permissionIds);
        this.setRoleAndMenu(roleId, menuIds);*/
   // }
}
